home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dec92.zip / 1012016A < prev    next >
Text File  |  1992-10-06  |  362b  |  15 lines

  1. /* strcspn function */
  2. #include <string.h>
  3.  
  4. size_t (strcspn)(const char *s1, const char *s2)
  5.     {    /* find index of first s1[i] that matches any s2[] */
  6.     const char *sc1, *sc2;
  7.  
  8.     for (sc1 = s1; *sc1 != '\0'; ++sc1)
  9.         for (sc2 = s2; *sc2 != '\0'; ++sc2)
  10.             if (*sc1 == *sc2)
  11.                 return (sc1 - s1);
  12.     return (sc1 - s1);    /* terminating nulls match */
  13.     }
  14.  
  15.